package Advice;

import Exceptions.*;
import Pojo.JesonResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalExceptionHandler {
    private static final Logger log= LoggerFactory.getLogger(GlobalExceptionHandler.class);
    @ExceptionHandler(ServiceException.class)
    public JesonResult doServiceException(ServiceException e){
        log.error("exception message {}",e.getMessage());
        return new JesonResult(e);
    }
    @ExceptionHandler(DeleteException.class)
    public JesonResult doDeleteException(DeleteException e){
        log.error("exception message {}", e.getMessage());
        return new JesonResult(e);
    }
    @ExceptionHandler(UpdateException.class)
    public JesonResult doUpdateException(UpdateException e){
        log.error("exception message {}",e.getMessage());
        return new JesonResult(e);
    }
    @ExceptionHandler(InsertException.class)
    public JesonResult doInsertException(InsertException e){
        log.error("exception message {}", e.getMessage());
        return new JesonResult(e);
    }
    @ExceptionHandler(SelectException.class)
    public JesonResult doSelectException(SelectException e){
        log.error("exception message {}", e.getMessage());
        return new JesonResult(e);
    }



}
